package case2Object_oriented;

/**
 * @program: AlibabaJavaIntroduction
 * @description: 对象引用分析**
 * @author: 朱志文
 * @create: 2021-12-21 22:02
 **/
public class Test5Object_Reference_Analysis {
    public static void main(String[] args) {
        //定义一个引用传递的分析程序
        Person person1 = new Person(); //


        // 声明并实例化对象
        person1.setName("张三");
        person1.setAge(18);
        Person person2=person1;
        person2.setAge(20);
        person1.tell();
        change(person2);  //这句话等价于 Person temp=person2
        person1.tell();
    }
    public static void change(Person temp){
        temp.setAge(22);
    }
}
